package br.com.quad.seguranca.managedBean.converte;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import br.com.quad.seguranca.bean.Sistema;
import br.com.quad.seguranca.dao.DAOFactory;


@FacesConverter(value="converteSistema", forClass=Sistema.class)
public class ConverteSistema implements Converter {

	@Override
	public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {		
		return DAOFactory.getSistemaDAO().getSistema(Integer.valueOf(arg2));		
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
		return String.valueOf(((Sistema) arg2).getCodigoSistema());
	}

}
